﻿using System.Collections.Generic;
using System.Windows.Automation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using QuickUIT.Controls;

namespace QuickUIT.Tests
{
    [TestClass]
    public class UITextTests
    {
        private BaseState _baseState;

        [TestInitialize]
        public void TestSetup()
        {
            _baseState = new BaseState(TestUtilities.GetTestApplicationFileName(), "@Name='QuickUIT Test Application'");
            _baseState.Execute();
        }

        [TestMethod]
        public void ShouldGetColumn()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIText textControl = window.UIText("@AutomationId='textBlock1'"); 
            Assert.AreEqual(-1, textControl.Column);
        }

        [TestMethod]
        public void ShouldGetColumnSpan()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIText textControl = window.UIText("@AutomationId='textBlock1'");
            Assert.AreEqual(-1, textControl.ColumnSpan);
        }

        [TestMethod]
        public void ShouldGetRow()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIText textControl = window.UIText("@AutomationId='textBlock1'");
            Assert.AreEqual(-1, textControl.Row);
        }

        [TestMethod]
        public void ShouldGetDocumentRange()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIText textControl = window.UIText("@AutomationId='textBlock1'");
            Assert.AreEqual(null, textControl.DocumentRange);
        }

        [TestMethod]
        public void ShouldGetSupportedTextSelection()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIText textControl = window.UIText("@AutomationId='textBlock1'");
            Assert.AreEqual(SupportedTextSelection.None, textControl.SupportedTextSelection);
        }

        [TestMethod]
        public void ShouldGetRowSpan()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIText textControl = window.UIText("@AutomationId='textBlock1'");
            Assert.AreEqual(-1, textControl.RowSpan);
        }

        [TestMethod]
        public void ShouldGetAllTextControls()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            List<UIText> textControls = window.UITexts();
            Assert.AreEqual(55, textControls.Count);
        }

        [TestCleanup]
        public void TestTeardown()
        {
            _baseState.Cleanup();
        }
    }
}